package com.woniu.smallmedical.server.serverimpl;

import com.woniu.smallmedical.entity.*;
import com.woniu.smallmedical.mapper.CostMapper;
import com.woniu.smallmedical.server.CostServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class CostServerImpl implements CostServer {
    @Autowired
    CostMapper costMapper;

    @Override
    public List<OrderType> getAllOrderType() {
        List<OrderType> orderTypes = costMapper.selectAllOrderType();
        return orderTypes;
    }

    @Override
    public int getCostCount(Cost cost, String costTimeStart, String costTimeEnd) {
        int costCount = costMapper.selectCostCount(cost, costTimeStart, costTimeEnd);
        return costCount;
    }

    @Override
    public List<Cost> getAllCost(Cost cost, String costTimeStart, String costTimeEnd, int pageIndex, int pageSize) {

        List<Cost> costs = costMapper.selectAllCost(cost, costTimeStart, costTimeEnd, pageIndex, pageSize);

        return costs;
    }

    @Override
    public PatientInformation getPatienById(String patienId) {
        PatientInformation patient = costMapper.PatientInformationById(patienId);
        return patient;
    }

    @Override
    public PatientInformation getPatientByNumber(int patientnumber) {
        PatientInformation patient = costMapper.selectPatientByNumber(patientnumber);
        return patient;
    }

    @Override
    public User getUserById(int userId) {
        User user = costMapper.selectUserById(userId);
        return user;
    }

    @Override
    public Department getDepById(int did) {
        Department department = costMapper.selectDepById(did);
        return department;
    }

    @Override
    public Prescription getByPrescriptionId(Integer prid) {
        Prescription prescription = costMapper.selectByPrescriptionId(prid);
        return prescription;
    }

    @Override
    public Registration getRegByPatId(int rid) {
        Registration registration = costMapper.selectRegByPatId(rid);
        return registration;
    }

    @Override
    public Receptiontype getReceptiontypeById(int receptiontypeid) {
        Receptiontype receptiontype = costMapper.selectReceptiontypeById(receptiontypeid);
        return receptiontype;
    }

    @Override
    public Prescription getPrescriptionById(int rid) {
        Prescription prescription = costMapper.selectPrescriptionById(rid);
        return prescription;
    }

    @Override
    public List<PrescriptionDetails> getPrescriptionDetailsById(int prid) {
        List<PrescriptionDetails> prescriptionDetails = costMapper.selectprescriptionDetailsById(prid);
        return prescriptionDetails;
    }

    @Override
    public void updatePayStateByPrid(int prid) {
        costMapper.updatePayStateIdByPrid(prid);
    }

    @Override
    public void updateOrderType(int prid, int orderTypeId) {
        costMapper.updateorderTypeId(prid, orderTypeId);
    }

    @Override
    public void updateInvenCountById(Integer inid, Integer count) {
        costMapper.updateInventoryCountById(inid, count);
    }

    @Override
    public void updateCostTime(Integer prid, Date costTime) {
        costMapper.updateCostTime(prid, costTime);
    }

    @Override
    public void insertIntoCost(Cost cost) {
        costMapper.insertCost(cost);
    }

    @Override
    public List<Prescription> getAllPrescription() {
        List<Prescription> prescriptions = costMapper.selectAllPrescription();
        return prescriptions;
    }

    @Override
    public Cost getCosts(Integer prid) {
        Cost cost = costMapper.selectCosts(prid);
        return cost;
    }

    @Override
    public void updatePayId(Integer payMethodId,Integer prid) {
        costMapper.updatePayMethod(payMethodId,prid);
    }


}
